home *** CD-ROM | disk | FTP | other *** search
- head 1.17;
- branch ;
- access ;
- symbols ;
- locks jhh:1.17; strict;
- comment @@;
-
-
- 1.17
- date 91.04.03.21.48.08; author rab; state Exp;
- branches ;
- next 1.16;
-
- 1.16
- date 90.11.05.05.41.25; author jhh; state Exp;
- branches ;
- next 1.15;
-
- 1.15
- date 90.03.12.23.26.17; author jhh; state Exp;
- branches ;
- next 1.14;
-
- 1.14
- date 90.01.15.18.49.22; author tve; state Exp;
- branches ;
- next 1.13;
-
- 1.13
- date 90.01.15.18.48.40; author tve; state Exp;
- branches ;
- next 1.12;
-
- 1.12
- date 89.07.18.16.01.36; author ouster; state Exp;
- branches ;
- next 1.11;
-
- 1.11
- date 89.07.18.14.42.16; author jhh; state Exp;
- branches ;
- next 1.10;
-
- 1.10
- date 89.04.06.21.40.12; author jhh; state Exp;
- branches ;
- next 1.9;
-
- 1.9
- date 88.08.13.11.57.04; author ouster; state Exp;
- branches ;
- next 1.8;
-
- 1.8
- date 88.07.20.13.34.32; author douglis; state Exp;
- branches ;
- next 1.7;
-
- 1.7
- date 88.07.20.10.22.21; author ouster; state Exp;
- branches ;
- next 1.6;
-
- 1.6
- date 88.06.17.16.27.51; author ouster; state Exp;
- branches ;
- next 1.5;
-
- 1.5
- date 88.06.17.13.59.08; author ouster; state Exp;
- branches ;
- next 1.4;
-
- 1.4
- date 88.06.06.17.23.20; author ouster; state Exp;
- branches ;
- next 1.3;
-
- 1.3
- date 88.06.06.08.34.32; author ouster; state Exp;
- branches ;
- next 1.2;
-
- 1.2
- date 88.06.05.11.39.07; author ouster; state Exp;
- branches ;
- next 1.1;
-
- 1.1
- date 88.06.02.17.19.32; author ouster; state Exp;
- branches ;
- next ;
-
-
- desc
- @@
-
-
- 1.17
- log
- @Add C++ support (Mike checking in for Bob).
- @
- text
- @#!/sprite/cmds/csh -f
- #
- # A script to generate the Makefile for a subdirectory that contains
- # machine-dependent sources and objects. If ./Makefile.proto exists,
- # use it, else use a default prototype.
- #
- # We assume we were invoked from mkmf. Parameters passed in from mkmf
- # through environment variables:
- #
- # Parameters passed in from mkmf as environment variables:
- # MKMFDIR directory containing prototype makefiles
- # MAKEFILE name of makefile to create
- # PARENTDIR name of parent directory (.. is fooled by symbolic
- # links)
- #
- # Variables generated here:
- # dir name of this subdirectory
- # machine name of machine type for this directory (e.g. "sun3")
- # pref prefix pattern that files must match to be included
- # makefile name of the makefile to create
- # proto name of prototype makefile to use to create $makefile
- #
-
- #
- # Argument processing. (Generalized form, even though just one flag so far.)
- #
- while ($#argv >= 1)
- if ("$1" == '-x') then
- set echo
- endif
- shift
- end
-
- set machine=$cwd:t
- set machine=$machine:r
- set pref='[0-9a-z_A-Z]'
-
- if ($?MAKEFILE) then
- set makefile=$MAKEFILE
- else
- set makefile=Makefile
- endif
-
- if (-e $makefile.proto) then
- set proto=$makefile.proto
- else
- set proto="${MKMFDIR}/Makefile.md"
- endif
-
- set dir=$cwd:t
- set machine=$dir:r
- set parent=$cwd:h
- set parent=$parent:t
- echo "Generating $makefile for $parent/$dir using $proto"
-
- if ($?PARENTDIR) then
- set parentdir=$PARENTDIR
- else
- set parentdir=..
- endif
-
- #
- # First figure out what's here by way of .c, .y, .l, .s, .p, .h
- # and .o files. For sources, look both in this directory and in
- # the parent (machine-independent) directory.
- #
- # If any one doesn't have any members, it'll contain the original
- # pattern (b/c of nonomatch). We want it to be empty, though, so
- # we reset it.
- #
- set nonomatch
- set tmp=( ${pref}*.{c,y,l,s,p,cc} )
- #
- # Check to see if there were any sources. The first check (size == 1)
- # is only necessary because the second check will cause an error if
- # allSrcs contains more than 1024 bytes.
- #
- if ($#tmp == 1) then
- if ("$tmp" == "${pref}*.{c,y,l,s,p,cc}") set tmp=()
- endif
- set srcs=()
- foreach i ($tmp)
- set srcs=($srcs $dir/$i)
- end
- set tmp=( ${parentdir}/${pref}*.{c,y,l,s,p,cc} )
- if ($#tmp == 1) then
- if ("$tmp" == "${parentdir}/${pref}*.{c,y,l,s,p,cc}") set tmp=()
- endif
-
- foreach i ($tmp:gt)
- if (! -e $i) then
- set srcs = ($srcs $i)
- endif
- end
-
- set tmp=( ${pref}*.h )
- if ($#tmp == 1) then
- if ("$tmp" == "${pref}*.h") set tmp=()
- endif
- set hdrs=()
- foreach i ($tmp)
- set hdrs=($hdrs $dir/$i)
- end
- set tmp=( ${parentdir}/${pref}*.h )
- if ($#tmp == 1) then
- if ("$tmp" == "${parentdir}/${pref}*.h") set tmp=()
- endif
- foreach i ($tmp:gt)
- if (! -e $i) then
- set hdrs = ($hdrs $i)
- endif
- end
-
- set tmp=( ${parent}*.h )
- if ($#tmp == 1) then
- if ("$tmp" == "${parent}*.h") set tmp=()
- endif
- set pubHdrs=()
- foreach i ($tmp)
- set pubHdrs=($pubHdrs $dir/$i)
- end
- set pubHdrs=(`echo $pubHdrs | sed -e "s/[^ ]*Int.h//g"`)
-
- #
- # Find miscellaneous files needed for builds (Makefiles, etc).
- #
- set tmp=( md.mk md.mk.sed dependencies.mk )
- set instfiles=()
- foreach i ($tmp)
- if (-e $i) then
- set instfiles=($instfiles $dir/$i)
- endif
- end
- set tmp=( Makefile local.mk Makefile.sed Makefile.ex tags TAGS )
- foreach i ($tmp)
- if (-e ${parentdir}/$i) then
- set instfiles = ($instfiles $i)
- endif
- end
-
-
- rm -f version.o
- set tmp=( ${pref}*.o )
- #
- # Check to see if there were any object files. The first check (size == 1)
- # is only necessary because the second check will cause an error if
- # tmp contains more than 1024 bytes.
- #
- if ($#tmp == 1) then
- if ("$tmp" == "${pref}*.o") set tmp=()
- endif
- set objs=()
- foreach i ($tmp)
- set objs=($objs $dir/$i)
- end
- unset nonomatch
-
- #
- # Merge in any .o files that can be created from local source files but don't
- # exist yet. In addition, figure out which .o files may be safely removed
- # during a "make clean" and store them in RmOfiles.
- #
- set RmOfiles=""
- if ($#srcs != 0) then
- foreach file ($srcs)
- set file=$file:t
- set file=$file:r.o
- set RmOfiles=($RmOfiles $dir/$file)
- if (! -e $file) set objs=($objs $dir/$file)
- end
- endif
-
- set sacredObjs=""
- foreach file ($objs)
- set tmp = $file:r
- echo $RmOfiles | grep $file > /dev/null
- if ($status && ($tmp:t != $parentdir:t)) then
- set sacredObjs = ($sacredObjs $file)
- echo "WARNING: file $file does not have a source file"
- endif
- end
-
- #
- # Use sed to substitute various interesting things into the prototype
- # makefile. The code below is a bit tricky because some of the variables
- # being substituted in can be very long: if the substitution is passed
- # to sed with "-e", the entire variable must fit in a single shell argument,
- # with a limit of 1024 characters. By generating a separate script file
- # for the very long variables, the variables get passed through (to the
- # script file) as many arguments, which gets around the length problem.
- #
-
- rm -f mkmf.tmp.sed
- echo s,"@@(SRCS)",$srcs,g > mkmf.tmp.sed
- echo s,"@@(OBJS)",$objs,g >> mkmf.tmp.sed
- echo s,"@@(CLEANOBJS)",$RmOfiles,g >> mkmf.tmp.sed
- echo s,"@@(HDRS)",$hdrs,g >> mkmf.tmp.sed
- echo s,"@@(INSTFILES)",$instfiles,g >> mkmf.tmp.sed
- echo s,"@@(SACREDOBJS)",$sacredObjs,g >> mkmf.tmp.sed
-
- cat $proto | sed -f mkmf.tmp.sed \
- -e "s,@@(PUBHDRS),$pubHdrs,g" \
- -e "s,@@(TEMPLATE),$proto,g" \
- -e "s,@@(DATE),`date`,g" > $makefile
- rm -f mkmf.tmp.sed
- @
-
-
- 1.16
- log
- @Warn if an object file does not have a source file.
- @
- text
- @d72 1
- a72 1
- set tmp=( ${pref}*.[cylsp] )
- d79 1
- a79 1
- if ("$tmp" == "${pref}*.[cylsp]") set tmp=()
- d85 1
- a85 1
- set tmp=( ${parentdir}/${pref}*.[cylsp] )
- d87 1
- a87 1
- if ("$tmp" == "${parentdir}/${pref}*.[cylsp]") set tmp=()
- @
-
-
- 1.15
- log
- @sets a variable with names of object files for which there
- are no sources
- @
- text
- @d175 1
- d177 1
- a177 1
- if ($status) then
- d179 1
- d182 1
- @
-
-
- 1.14
- log
- @allow source files to start with digits
- @
- text
- @d124 18
- d173 7
- d195 2
- @
-
-
- 1.13
- log
- @*** empty log message ***
- @
- text
- @d36 1
- a36 1
- set pref='[a-z_A-Z]'
- @
-
-
- 1.12
- log
- @Require module prefix for a header to be considered public.
- @
- text
- @d126 8
- a133 1
- if ("$tmp" == "${pref}*.o") set tmp=()
- d169 1
- a171 1
- -e "s,@@(HDRS),$hdrs,g" \
- @
-
-
- 1.11
- log
- @allow there to be both machine dependent and independent versions of files
- @
- text
- @a100 1
- set pubHdrs=()
- a103 1
- set pubHdrs=(`echo $hdrs | sed -e "s/[^ ]*Int.h//g"`)
- a107 1
-
- d113 10
- @
-
-
- 1.10
- log
- @added abilty to make specific machine types
- @
- text
- @a88 1
- set srcs=($srcs $tmp:gt)
- d90 6
- d110 6
- a115 1
- set hdrs=($hdrs $tmp:gt)
- @
-
-
- 1.9
- log
- @Added "-x" switch.
- @
- text
- @d13 2
- d56 6
- d85 1
- a85 1
- set tmp=( ../${pref}*.[cylsp] )
- d87 1
- a87 1
- if ("$tmp" == "../${pref}*.[cylsp]") set tmp=()
- d92 3
- a94 1
- if ("$tmp" == "${pref}*.h") set tmp=()
- d101 4
- a104 2
- set tmp=( ../${pref}*.h )
- if ("$tmp" == "../${pref}*.h") set tmp=()
- @
-
-
- 1.8
- log
- @fixed a typo causing each file to be included twice in list
- of file names.
- @
- text
- @d21 11
- @
-
-
- 1.7
- log
- @Add code to be more careful about long lists of source files.
- @
- text
- @d68 1
- a68 1
- if ("$tmp" == "${pref}*.[cylsp]") set tmp=()
- @
-
-
- 1.6
- log
- @Changes to handle directories with many many files.
- @
- text
- @d54 8
- a61 1
- if ("$tmp" == "${pref}*.[cylsp]") set tmp=()
- d67 3
- a69 1
- if ("$tmp" == "../${pref}*.[cylsp]") set tmp=()
- d99 1
- a99 1
- if ("$srcs" != "") then
- @
-
-
- 1.5
- log
- @Wasn't getting pubhdrs right.
- @
- text
- @a20 1
-
- d99 16
- a114 2
- cat $proto | sed \
- -e "s,@@(SRCS),$srcs,g" \
- a116 2
- -e "s,@@(OBJS),$objs,g" \
- -e "s,@@(CLEANOBJS),$RmOfiles,g" \
- d119 1
- @
-
-
- 1.4
- log
- @Generate MDPUBHDRS to identify machine-dependent public headers.
- @
- text
- @a69 3
- if ("$i" !~ " *Int.h") then
- set pubHdrs=($pubHdrs $dir/$i)
- endif
- d71 1
- @
-
-
- 1.3
- log
- @Print out name of actual makefile, not "Makefile".
- @
- text
- @d67 1
- d70 3
- d105 1
- @
-
-
- 1.2
- log
- @Various revisions to generate Makefiles for multi-directory
- libraries with multiple target machines.
- @
- text
- @d42 1
- a42 1
- echo "Generating a Makefile for $parent/$dir using $proto"
- @
-
-
- 1.1
- log
- @Initial revision
- @
- text
- @d3 2
- a4 2
- # A script to generate the Makefile for a machine-dependent subdirectory
- # of the source directory for a command. If ./Makefile.proto exists,
- d7 2
- a8 3
- # We assume we were invoked from mkmf, thus we don't need to alter the
- # path, and MKMFDIR is in the environment to tell us where to find prototype
- # makefiles, etc.
- d15 1
- d35 1
- a35 1
- set proto="${MKMFDIR}/Makefile.command.md"
- d40 3
- a42 3
- set dir2=$cwd:h
- set dir2=$dir2:t
- echo "Generating a Makefile for $dir2/$dir using $proto"
- d45 3
- a47 3
- # First figure out what's there by way of .c, .y, .l, .s, .p, .h
- # and .o files. For sources, look both in this directory and in the
- # parent (machine-independent) directory.
- @
-